package com.google.gwt.sample.dynatablerf.client.presenters;

import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.event.dom.client.HasClickHandlers;
import com.google.gwt.event.shared.EventBus;
import com.google.gwt.sample.dynatablerf.client.events.GoToMaterialListEvent;
import com.google.gwt.sample.dynatablerf.client.events.GoToServicoListEvent;
import com.google.gwt.sample.dynatablerf.shared.ProjetoProxy;

public class ProjetoStartPresenter extends AbstractTabPresenter {

	public interface ProjetoStartDisplay extends TabDisplay {

		HasClickHandlers getMaterialClickHandlers();

		HasClickHandlers getServicoClickHandlers();
	}

	private ProjetoStartDisplay projetoStartDisplay;
	private ProjetoProxy projetoProxy;

	public ProjetoStartPresenter(EventBus eventBus,
			ProjetoStartDisplay projetoStartDisplay, ProjetoProxy projetoProxy) {
		super(eventBus);
		this.projetoStartDisplay = projetoStartDisplay;
		this.projetoProxy = projetoProxy;
	}

	@Override
	protected void bind() {
		projetoStartDisplay.getMaterialClickHandlers().addClickHandler(
				new ClickHandler() {

					@Override
					public void onClick(ClickEvent event) {
						getEventBus().fireEvent(
								new GoToMaterialListEvent(projetoProxy,
										getTabLayoutPanel(), getEventBus()));

					}
				});

		projetoStartDisplay.getServicoClickHandlers().addClickHandler(
				new ClickHandler() {

					@Override
					public void onClick(ClickEvent event) {
						getEventBus().fireEvent(
								new GoToServicoListEvent(projetoProxy,
										getTabLayoutPanel(), getEventBus()));

					}
				});

	}

	@Override
	protected TabDisplay getTabDisplay() {
		return projetoStartDisplay;
	}

}